home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 May / PC för Alla 0505.iso / fullversioner / realsoft3d / data1.cab / Scripting / scripts / js / myclasses / windows / myCallbacktestWin.js next >
Encoding:
Text File  |  2005-04-04  |  1.8 KB  |  72 lines

  1.  
  2. //
  3. // Description:
  4. //      Window callback example. Defines a new window class which uses callback function 
  5. //      to report window events to the user.
  6. //
  7. // Super class:
  8. //      oops/r3window.js
  9. //
  10. // Constructor:
  11. //      obj = new myCallbackWindow(tag list);
  12. //
  13. //
  14.  
  15. include("oops/r3window.js");
  16. include("oops/r3packer.js");
  17. include("oops/r3text.js");
  18.  
  19. // function for handling window events
  20.  
  21. function myCallbackTestHook(win, method, val)
  22. {
  23.     if(method == R3WM_CLOSEWINDOW) {
  24.         this.info.SetText("Closewindow");
  25.     }
  26.     else if(method == R3WM_NEWSIZE) {
  27.         this.info.SetText("Newsize");
  28.     }
  29.     else if(method == R3WM_MOUSEMOVE) {
  30.         this.info.SetText("MouseMove");
  31.     }
  32.     else if(method == R3WM_LMBDOWN) {
  33.         this.info.SetText("Left mouse button down");
  34.     }    
  35.     else if(method == R3WM_LMBUP) {
  36.         this.info.SetText("Left mouse button up");
  37.     }
  38.     else {
  39.         this.info.SetText("Event Id: " + method);
  40.     }
  41.     return 1;
  42. }
  43.  
  44. // constructor
  45.  
  46. function myCallbackTestWin()
  47. {
  48.     // call super class 
  49.     if(arguments.length == 0)
  50.         return;
  51.     this.base = r3Window;
  52.     this.base(R3WA_ReportNewSize, TRUE,
  53.               R3WA_ReportCloseWindow, TRUE,
  54.               R3WA_Title, "My Callback test",
  55.               R3RA_Hook, myCallbackTestHook,
  56.               arguments);
  57.  
  58.     // create a info field
  59.     this.info = new r3Text(R3WGA_Parent, this,
  60.                         R3GA_Text, "Event");
  61.  
  62.     // tell the hook function where to find the info field
  63.     myCallbackTestHook.info = this.info;
  64.  
  65.     // use packer to manage the info field
  66.     this.packer = new r3Packer(R3PA_Orientation, R3PAOF_VERTICAL);
  67.     this.packer.ADD(R3PAPF_FILLX, 0, this.info);
  68.     this.SetGmanager(this.packer);
  69. }
  70.  
  71. myCallbackTestWin.prototype=new r3Window;
  72.